package com.rule.front.api.drools;

import com.rule.drools.entity.PropertyRelEntity;
import com.rule.drools.service.PropertyRelService;
import com.rule.core.utils.PageUtils;
import com.rule.core.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 规则属性配置表
 *
 * @author gz
 * @email 360568523@qq.com
 * @date 2019-05-25 14:54:38
 */
@RestController
@RequestMapping("rules/propertyrel")
public class PropertyRelController {
    @Autowired
    private PropertyRelService propertyRelService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = propertyRelService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{ruleProRelId}")
    public Result info(@PathVariable("ruleProRelId") Long ruleProRelId){
		PropertyRelEntity propertyRel = propertyRelService.getById(ruleProRelId);

        return Result.ok().put("propertyRel", propertyRel);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody PropertyRelEntity propertyRel){
		propertyRelService.save(propertyRel);

        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody PropertyRelEntity propertyRel){
		propertyRelService.updateById(propertyRel);

        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Long[] ruleProRelIds){
		propertyRelService.removeByIds(Arrays.asList(ruleProRelIds));

        return Result.ok();
    }

}
